<script>
	export default {
		onLaunch: function() {
			console.log('App Launch');
			// #ifdef APP-NVUE
			plus.screen.lockOrientation('portrait-primary');

			let appid = plus.runtime.appid;
			if (appid && appid.toLocaleLowerCase() != "hbuilder") {
				uni.request({
					url: 'https://uniapp.dcloud.io/update', //检查更新的服务器地址
					data: {
						appid: plus.runtime.appid,
						version: plus.runtime.version
					},
					success: (res) => {
						console.log('success', res);
						if (res.statusCode == 200 && res.data.isUpdate) {
							let openUrl = plus.os.name === 'iOS' ? res.data.iOS : res.data.Android;
							// 提醒用户更新
							uni.showModal({
								title: '更新提示',
								content: res.data.note ? res.data.note : '是否选择更新',
								success: (showResult) => {
									if (showResult.confirm) {
										plus.runtime.openURL(openUrl);
									}
								}
							})
						}
					}
				})
			}

			var domModule = weex.requireModule('dom');
			domModule.addRule('fontFace', {
				'fontFamily': "texticons",
				'src': "url('./static/text-icon.ttf')"
			});
			// #endif
		},
		onShow: function() {
			// function nav (move) {
			// 	const currentIndex = document.activeElement.tabIndex;
			// 	const next = currentIndex + move;
			// 	const items = document.querySelectorAll('.items');
			// 	const targetElement = items[next];
			// 	targetElement.focus();
			// }
			function handleKeydown(e) {
				console.log('e', e)
				if(window.keydown){
					// e.preventDefault();
					window.keydown(e)
				}
				// switch(e.key) {
				// 	case 'ArrowUp':
				// 	nav(-1);
				// 	break;
				// 	case 'ArrowDown':
				// 	nav(1);
				// 	break;
				// 	case 'ArrowRight':
				// 	nav(1);
				// 	break;
				// 	case 'ArrowLeft':
				// 	nav(-1);
				// 	break;
				// }
			}
			// console.log('App Show')
			document.activeElement.addEventListener('keydown', handleKeydown);
			

		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	 .uni-page-head-hd{
		display: none!important;
	}
	/* .ad-display{
		position: fixed!important;
		top:0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 10;
	} */
</style>
